package com.itheima.job;

import com.itheima.utils.QiNiuUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.Date;
import java.util.Set;

@Component
public class ClearImgJob {
    @Autowired
    private JedisPool jedisPool;

    public void run(){
//        System.out.println(new Date());
//        System.out.println("开始清理");
//        //清理垃圾图片
//        try (Jedis jedis = jedisPool.getResource()) {
//            Set<String> sdiff = jedis.sdiff("SETMEAL_ALL", "SETMEAL_SAVE_ALL");
//            for (String fileName : sdiff) {
//                QiNiuUtil.delete(fileName);
//                jedis.srem("SETMEAL_ALL",fileName);
//                System.out.println("清理的图片:"+fileName);
//            }
//            System.out.println("清理完成");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }
}
